package com.example.train.business.controller;

import com.example.train.common.context.LoginMemberContext;
import com.example.train.common.resp.CommonResp;
import com.example.train.common.resp.PageResp;
import com.example.train.business.req.Train_SeatQueryReq;
import com.example.train.business.req.Train_SeatSaveReq;
import com.example.train.business.resp.Train_SeatQueryResp;
import com.example.train.business.service.Train_SeatService;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/train_Seat")

public class Train_SeatController {

    @Resource
    private Train_SeatService train_SeatService;

    /**
     * 乘客注册请求的controller类，用于调用service
     * 注意PostMapping必须要用requestBody注解，否则后端接受不到数据
     * @param train_SeatSaveReq
     * @return
     */
    @PostMapping("/save")
    public CommonResp<Object> save(@Valid @RequestBody Train_SeatSaveReq train_SeatSaveReq) {
        train_SeatService.save(train_SeatSaveReq);
        return new CommonResp<>();
    }
    /**
     * 查询当前会员下乘客信息列表的controller类，用于调用service
     * 注意GetMapping不用requestBody注解，否则后端接受不到数据
     * @param @VALID Train_SeatQueryReq
     * @return CommonResp<PageResp<Train_SeatQueryResp>>
     */
    @GetMapping("/query-list")
    public CommonResp<PageResp<Train_SeatQueryResp>> queryList(@Valid Train_SeatQueryReq req) {
        PageResp<Train_SeatQueryResp> list = train_SeatService.queryList(req);
        return new CommonResp<>(list);
    }

    /**
     * 删除乘客信息的controller层接口
     * @param id
     * @return CommonResp<Object>
     */
    @DeleteMapping("/delete/{id}")
    public CommonResp<Object> delete(@PathVariable Long id) {
        train_SeatService.delete(id);
        return new CommonResp<>();
    }

}

